import { request } from "./index"

//* --------获取歌曲详情，没有播放地址-------------

export interface SongDetailModel {
  name: string //歌名
  id: number
  fee: number //和track里面的fee一样，值为1表示vip标识
  dt: number //歌曲时长,毫秒
  //下面这两个字段是自己加的字段
  maxbr: number //播放最大比特率，大于320000表示有SQ品质标识 也就是999000。还有downloadMaxbr表示下载
  subp: 1 | 0 //1表示完成，0表示是试听标识
  ar: {
    id: number
    name: string //歌手名
  }[]
  al: {
    id: number
    name: string //专辑名
    picUrl: string //封面
  }
}

export const reqSongDetail = (ids: number) =>
  request<{ songs: SongDetailModel[] }>({
    url: "/song/detail",
    params: { ids },
  })

//* -----------获取歌曲播放地址------------

export interface SongUrlModel {
  id: number
  url: string | null //播放url,如果是要购买的歌曲等没有权限的情况下将会是null
  br: number //码率
}

//还能传一个参数br 表示码率 默认最大
export const reqSongUrl = (id: number) =>
  request<{ data: SongUrlModel[] }>({
    url: "/song/url",
    params: { id },
  })

//* -------------------获取喜欢的音乐的id数组----------------------------
export const reqLikeSongId = (uid: number) =>
  request<{ ids: number[] }>({
    url: "/likelist",
    params: { uid },
  })

//获取歌曲评论，只获取1条，只为了拿到总数
export const reqSongComment = (id: number) =>
  request<{ total: number }>({
    url: "/comment/music",
    params: { id, limit: 1 },
  })

export const reqLikeSong = (id: number, like: boolean) =>
  request<null>({
    url: "/like",
    params: { id, like },
  })
